package com.kookapi.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.kookapi.common.annotation.Log;
import com.kookapi.common.core.controller.BaseController;
import com.kookapi.common.core.domain.AjaxResult;
import com.kookapi.common.enums.BusinessType;
import com.kookapi.business.domain.TestScenarioData;
import com.kookapi.business.service.ITestScenarioDataService;
import com.kookapi.common.utils.poi.ExcelUtil;
import com.kookapi.common.core.page.TableDataInfo;

/**
 * 场景参数数据Controller
 * 
 * @author cleftgou
 * @date 2025-10-06
 */
@RestController
@RequestMapping("/business/scenarioData")
public class TestScenarioDataController extends BaseController
{
    @Autowired
    private ITestScenarioDataService testScenarioDataService;

    /**
     * 查询场景参数数据列表
     */
    @PreAuthorize("@ss.hasPermi('business:scenarioData:list')")
    @GetMapping("/list")
    public TableDataInfo list(TestScenarioData testScenarioData)
    {
        startPage();
        List<TestScenarioData> list = testScenarioDataService.selectTestScenarioDataList(testScenarioData);
        return getDataTable(list);
    }

    /**
     * 导出场景参数数据列表
     */
    @PreAuthorize("@ss.hasPermi('business:scenarioData:export')")
    @Log(title = "场景参数数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TestScenarioData testScenarioData)
    {
        List<TestScenarioData> list = testScenarioDataService.selectTestScenarioDataList(testScenarioData);
        ExcelUtil<TestScenarioData> util = new ExcelUtil<TestScenarioData>(TestScenarioData.class);
        util.exportExcel(response, list, "场景参数数据数据");
    }

    /**
     * 获取场景参数数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:scenarioData:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(testScenarioDataService.selectTestScenarioDataById(id));
    }

    /**
     * 新增场景参数数据
     */
    @PreAuthorize("@ss.hasPermi('business:scenarioData:add')")
    @Log(title = "场景参数数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TestScenarioData testScenarioData)
    {
        return toAjax(testScenarioDataService.insertTestScenarioData(testScenarioData));
    }

    /**
     * 修改场景参数数据
     */
    @PreAuthorize("@ss.hasPermi('business:scenarioData:edit')")
    @Log(title = "场景参数数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TestScenarioData testScenarioData)
    {
        return toAjax(testScenarioDataService.updateTestScenarioData(testScenarioData));
    }

    /**
     * 删除场景参数数据
     */
    @PreAuthorize("@ss.hasPermi('business:scenarioData:remove')")
    @Log(title = "场景参数数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(testScenarioDataService.deleteTestScenarioDataByIds(ids));
    }
}
